﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;


namespace DataManager
{
    public class DBConnection
    {
        private static DBConnection instance;

        private SqlConnection connection;


        public static DBConnection getInstance()
        {
            if (instance == null)
            {
                instance = new DBConnection();                
            }
            return instance;
        }

        public SqlConnection getConnection()
        {           
            if (connection == null)
            {
                connection = new SqlConnection();
                
                connection.ConnectionString = "Server=SqlServer;Database=Presentation_BD;Trusted_Connection=True;MultipleActiveResultSets=true";
                connection.Open();
            }
            else
            {
                if (connection.State == System.Data.ConnectionState.Closed)
                {                    
                    connection.Open();
                }
            }

            return connection;
        }
    }
}
